/*
    intalign.cpp

    Copyright (C) 2012 Leonardo Boquillon and Daniel Gutson, FuDePAN

    This file is part of Biorinox.

    Biorinox is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Biorinox is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <iostream>
#include <string>
#include <exception>

#include "getoptpp/getopt_pp.h"
#include "IntersectAlignments.h"

using namespace GetOpt;

int main(int argc, char* argv[])
{
    GetOpt_pp op(argc, argv);

    int ret = EXIT_FAILURE;

    std::string input1;
    std::string input2;
    std::string output1;
    std::string output2;
    std::string prefix1;
    std::string prefix2;

    op >> Option('I', "input1", input1) >> Option('i', "input2", input2);
    op >> Option('O', "output1", output1) >> Option('o', "output2", output2);
    op >> Option('P', "prefix1", prefix1) >> Option('p', "prefix2", prefix2);

    if (!input1.empty() && !input2.empty() && !output1.empty() && !output2.empty())
    {

        try
        {
            IntersectAlignments ia(
                input1, input2, output1, output2, prefix1, prefix2
            );

            ia.run();
            ret = EXIT_SUCCESS;
        }
        catch (const std::exception& ex)
        {
            std::cerr << ex.what() << std::endl;
        }
    }
    else
    {
        std::cerr << "Missing parameter"  << std::endl;
    }

    return ret;
}
